

package examples.radio;

import commandz.cli.*;
import commandz.var.*;
import java.util.Collection;


/**
 *  Command for adjusting the volume of a given Radio.
 */
public final class VolumeCommand implements Command
{
    private VariableInteger volume;
    private Radio radio;


    public VolumeCommand(Radio radio)
    {
        this.radio = radio;
        this.volume = new VariableInteger();
    }


    public String getName()
    {
        return "volume";
    }


    public String getDescription()
    {
        return "Adjusts the amplification-level of the received signal.";
    }


    public void publishParameters(Collection<Parameter> params)
    {
        params.add(new Parameter(this.volume, "level", "A volume-level."));
    }


    public void execute()
    {
        this.radio.setVolume(this.volume.getValue());

        System.out.printf("Volume: %d.\n", this.radio.getVolume());
    }
}
